﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace FoundationLib.Ifc.Logging.Configuration
{
	/// <summary>
	/// This class represents a configuration section for loggers.
	/// </summary>
	public class LoggerConfigSection : ConfigurationSection
	{
		/// <summary>
		/// The name of the config section in the config file
		/// </summary>
		private const string SECTION_NAME = "loggerConfiguration";

		/// <summary>
		/// Creates a new logger configuration section
		/// </summary>
		public LoggerConfigSection() : base()
		{
		}

		/// <summary>
		/// Returns the logger configuration section from the config file.
		/// </summary>
		/// <returns>The logger configuration section</returns>
		public static LoggerConfigSection FromConfiguration()
		{
			return (ConfigurationManager.GetSection(SECTION_NAME) as LoggerConfigSection);
		}

		/// <summary>
		/// Gets a collection of loggers defined in this section.
		/// </summary>
		[ConfigurationCollection(typeof(LoggerCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
		[ConfigurationProperty("loggers", IsRequired = true)]
		public LoggerCollection Loggers
		{
			get
			{
				return (this["loggers"] as LoggerCollection);
			}
		}
	}
}
